// pages/shopkeeper/shopkeeper.js
import base from '../../config/base.js';
import myindexService from '../../services/myindex.js'
import service_conch from '../../services/conch';




Page({

  /**
   * 页面的初始数据
   */
  data: {
    img_bgc1: base.static + 'shopkeeper/sharetit13.png',
    img_bgc2: base.static + 'shopkeeper/imgbgc2.jpg',
    img_bgc3: base.static + 'shopkeeper/sharetit33.png',
    img_bgc4: base.static + 'shopkeeper/sharetit44.jpg',
    img_bgc5: base.static + 'shopkeeper/sharetit55.jpg',
    icon_no_avater: base.static + '/free/head.png',  
    share_add: base.static + 'shopkeeper/shareadd.png',
    avatar:'',
    num_x: '',
    num_x: '',
    list: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      avatar: wx.getStorageSync('user_info').avatar
      
    })
    this.getshowshareinfo()
    this.signDetail();
  },
  //通过邀请好友签到的头像和数量
  getshowshareinfo() {
    let that = this;
    myindexService.showshareinfo({}, function (res) {
      if (res && res.code == 1) {
        that.setData({
          num_x: res.data.x,
          num_y: res.data.y,
          list: res.data.avatar
        })
      }
    })
  },

  // 获取分享图片
  signDetail: function () {
    let that = this
    let params = {}
    service_conch.showdays(params, function (res) {
      if (res && res.code == 1) {
        that.setData({
          sharepath: res.data.share_img,
        })
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    let that = this;
    let user_info = wx.getStorageSync('user_info');
    let store_id = user_info.lastView.seid;
    let share_id = user_info.id;
    let title_arr = ['每天点一点，省钱不只一点点！', '点击签到，马上领钱！', '赚大了！连续签到7天就能得3元，有福同享，点就有', '帮我点一下，就能一起领钱', '哈哈哈！签到就能领钱，你也快来吧', '天生爱分享！签到领钱你听说过吗？', '不好意思，这钱是你掉的吗？', '天上掉馅饼啦！每天签到，就能领钱', '有些钱，该领就得领', '有钱不领，你是认真的吗？']
    let index = Math.floor(Math.random() * (title_arr.length));
    let paths = '';
    paths = 'pages/store/index?store_id=' + store_id + '&to=' + encodeURIComponent('/pages/conch/conch?store_id=' + store_id + '&share_id=' + share_id + '&sharerecord=conchcard' + '&user_id=' + share_id);
    return {
      title: title_arr[index],
      path: paths,
      imageUrl: 'https:' + that.data.sharepath,
    }
  }
})